<script setup>
import { computed, ref } from "vue"

const props = defineProps({
  data: {
    type: Object,
    default: null
  }
})

const summaryData = computed(() => !props.data ? [] : [props.data])

const columns = [
  {
    title: "学生人数", dataIndex: 'totalCount',
    children: [
      { title: "男", dataIndex: 'maleTotalCount', width: 70, align: 'center' },
      { title: "女", dataIndex: 'femaleTotalCount', width: 70, align: 'center' },
      { title: "合计", dataIndex: 'totalCount', width: 70, align: 'center' },
    ]
  }, {
    title: "实测学生数", dataIndex: 'testCount',
    children: [
      { title: "男", dataIndex: 'maleTestCount', width: 70, align: 'center' },
      { title: "女", dataIndex: 'femaleTestCount', width: 70, align: 'center' },
      { title: "合计", dataIndex: 'testCount', width: 70, align: 'center' },
    ]
  }, {
    title: "申请免测学生数", dataIndex: 'freeTestCount',
    children: [
      { title: "男", dataIndex: 'maleFreeTestCount', width: 70, align: 'center' },
      { title: "女", dataIndex: 'femaleFreeTestCount', width: 70, align: 'center' },
      { title: "合计", dataIndex: 'freeTestCount', width: 70, align: 'center' },
      { title: "占比", slotName: 'freeTestRate', width: 85, align: 'center' },
    ]
  }, {
    title: "优秀人数", dataIndex: 'bestCount',
    children: [
      { title: "男", dataIndex: 'maleBestCount', width: 70, align: 'center' },
      { title: "女", dataIndex: 'femaleBestCount', width: 70, align: 'center' },
      { title: "合计", dataIndex: 'bestCount', width: 70, align: 'center' },
      { title: "占比", slotName: 'bestRate', width: 85, align: 'center' },
    ]
  }, {
    title: "良好人数", dataIndex: 'wellCount',
    children: [
      { title: "男", dataIndex: 'maleWellCount', width: 70, align: 'center' },
      { title: "女", dataIndex: 'femaleWellCount', width: 70, align: 'center' },
      { title: "合计", dataIndex: 'wellCount', width: 70, align: 'center' },
      { title: "占比", slotName: 'wellRate', width: 85, align: 'center' },
    ]
  }, {
    title: "及格人数", dataIndex: 'passCount',
    children: [
      { title: "男", dataIndex: 'malePassCount', width: 70, align: 'center' },
      { title: "女", dataIndex: 'femalePassCount', width: 70, align: 'center' },
      { title: "合计", dataIndex: 'passCount', width: 70, align: 'center' },
      { title: "占比", slotName: 'passRate', width: 85, align: 'center' },
    ]
  }, {
    title: "不及格人数", dataIndex: 'noPassCount',
    children: [
      { title: "男", dataIndex: 'maleNoPassCount', width: 70, align: 'center' },
      { title: "女", dataIndex: 'femaleNoPassCount', width: 70, align: 'center' },
      { title: "合计", dataIndex: 'noPassCount', width: 70, align: 'center' },
      { title: "占比", slotName: 'noPassRate', width: 85, align: 'center' },
    ]
  }, {
    title: "合格率", slotName: 'qualifiedRate', width: 85
  }
]

</script>
<template>
  <a-card title="整体测试报表" style="margin-top: 16px;">
    <a-table :columns="columns" :data="summaryData" :bordered="{ headerCell: true }" :pagination="false">
      <template #freeTestRate="{ record }">
        {{ !record.freeTestRate ? "0%" : record.freeTestRate + "%" }}
      </template>
      <template #bestRate="{ record }">
        {{ record.bestRate + "%" }}
      </template>
      <template #wellRate="{ record }">
        {{ record.wellRate + "%" }}
      </template>
      <template #passRate="{ record }">
        {{ record.passRate + "%" }}
      </template>
      <template #noPassRate="{ record }">
        {{ record.noPassRate + "%" }}
      </template>
      <template #qualifiedRate="{ record }">
        {{ record.qualifiedRate + "%" }}
      </template>
    </a-table>
  </a-card>
</template>